<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@ include file="/sys/include/header.jsp" %>
<html>
<head> 
<title>权限管理</title>
<link href="sys//style01/css/table.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="sys/js/menutree/drighttree.js"></script>
<link rel="StyleSheet" href="sys/css/menutree/dtree.css" type="text/css" /> 
</head>  
<script type="text/javascript"> 
 
 	var menuId=new Array();
 	var menuPid=new Array();
 	
	//保存权限树
	function saverule(form){ 
		var id=new Array(form.elements.length);
		var result="";
		for (var i=0;i<form.elements.length;i++){
			var e = form.elements[i];
		    if (e.checked&&e.name!=undefined&&e.name!='roleId'&&e.name!='select') 
				result+=e.name+",";
		}
		if(document.getElementById("real_salary").value.length>70){
			alert("短信内容不能超过70个字，请确认");
			return;
		}
		if(result==""){
			alert("请选择需要发送的人员！");
			return;
		}else{
		alert(result);
			document.getElementById("ctmId").value=result;
			document.form1.submit();
		}		
	}
	
	
	//选择全部
	 function checkedall(form){
	 	for (var i=0;i<form.elements.length;i++){
	    	var e = form.elements[i];
	       	e.checked=true;
	   	}
	 }
	 
	 //取消全部
	 function uncheckedall(form){
	 for (var i=0;i<form.elements.length;i++){
	    	var e = form.elements[i];
	       	e.checked=false;
	   	}
	 }
	//联动设置
	function parent(el,e2){ 
		var id=el; 
		var pid=e2;
		var bool = document.getElementById(id).checked;
		for(var k=0;k<menuId.length;k++){
				if(menuPid[k]==id){
					var tid=menuId[k];
					document.getElementById(tid).checked = bool;
					var tpid=menuPid[k];
					parent(tid,tpid);					
				}
			}
	} 
 
</script>
 <body class="ridgeBody">
 <form name="form1" method="post"  action="message/noticeSendDo.action">
	<table width="100%">
	<tr><td>	
	<input type="hidden" value="" name="ctmId" id="ctmId" />
		<fieldset align='left' style="width:500"> 
		  <legend>
		  	<font  style="cursor:hand;" size="4"><img src="sys/images/getpic.gif">短信通知发送</font>
		  </legend>
		  <table id="tab4" style="display:block;" class=datatable width=500 cellpadding='0' cellspacing='0' border='1' bordercolorDark='white' bordercolorLight='#BEBEBE' >
			<tr><TD height="24"  valign="top" class="dataTitle" colspan="4"></TD></tr>
			<tr>
				<td  width="102" valign="top" >短信通知内容（限70个字）:
				</td>
			  	<td  width="500"  valign="top" colspan="3">
					<textarea id="real_salary" name="real_salary" cols="40"   rows="4" onpropertychange="if(value.length>70) value=value.substr(0,70)"  ></textarea>
			  	</td>
			  	
			</tr>
			<tr>
			  	<td width="602" valign="top" align="center" colspan="4">
			  		<c:if test="${!empty  bean}">
						<input type="button" onClick="saverule(form1)" value="发送通知"/>
					</c:if>
			  	</td>
			</tr>
			<tr>
				<td width="80%" valign="top" colspan="3" >				
				<c:if test="${!empty  bean}">				
					<div name="tree" id="tree" class="dtree"><script type="text/javascript">
						d = new dTree('d');
						d.add('a0','-1','系统功能菜单');	
						<c:forEach items="${bean}" var="menuAll">
							d.add('${menuAll.id}','${menuAll.pid}','${menuAll.name}','','','','','');
							menuId[menuId.length]	=	'${menuAll.id}';
 							menuPid[menuPid.length]	=	'${menuAll.pid}';
						</c:forEach>
						document.write(d);
						d.openAll();
					</script>						
					</div>					
				</c:if>
			  	</td>
			  	</tr>
		  </table>		  
		</fieldset>
	</td></tr>
	</table>
</form> 
</body>
</HTML>
